package com.pass.three;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

/**
 * Pass Three reads into all the nodes, as well as the result file produced by
 * Pass Two. It does spatial join on the nodes, then combines with the edges in
 * PassTwo results, do a final union find.
 * 
 * @author bh349
 */
public class PassThree extends Configured implements Tool {

	public int run(String[] args) throws Exception {
		Job job = new Job(getConf(), "pass 3");
		job.setJarByClass(PassThree.class);
		job.setMapperClass(PassThreeMapper.class);
		job.setReducerClass(PassThreeReducer.class);

		job.setOutputKeyClass(IntWritable.class);
		job.setOutputValueClass(Text.class);

		FileInputFormat.addInputPaths(job, "pass3");
		FileOutputFormat.setOutputPath(job, new Path("pass3out"));
		return job.waitForCompletion(true) ? 0 : 1;
	}
}
